<script>
export default {
  watch: {
    $route: {
      handler(to) {
        if (to.path.indexOf('redirect') >= 0) {
          this.redirect();
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    redirect() {
      const { params, query } = this.$route;
      const { path } = params;
      this.$router.replace({ path: '/' + path, query });
    }
  },
  render: function (h) {
    return h(); // avoid warning message
  }
}
</script>
